// 导入instance实例
import instance from '@/utils/axios.js'

// 封装函数，接口
// 1.登录接口
function userLogin ({ mobile, code }) {
  // 注意：一定要return
  return instance({
    url: '/v1_0/authorizations',
    method: 'post',
    // 解构赋值
    data: { mobile, code }
  })
}

// 导出接口
export { userLogin }

import { getToken } from '@/utils/token.js'
// 2.获取个人信息接口
function getUserInfo () {
  return instance({
    url: '/v1_0/user/profile',
    method: 'get'
    // headers: { Authorization: `Bearer ${getToken().token}` }
  })
}

export { getUserInfo }

// 3.修改个人信息接口
const editUserInfo = data => {
  return instance({
    url: '/v1_0/user/profile',
    method: 'patch',
    data
    // headers: { Authorization: `Bearer ${getToken().token}` }
  })
}
export { editUserInfo }

// 4.修改头像接口
const editAvatar = fd => {
  return instance({
    url: '/v1_0/user/photo',
    method: 'patch',
    data: fd
    // headers: { Authorization: `Bearer ${getToken().token}` }
  })
}
export { editAvatar }


